{% extends 'base.html' %}

{% block title %}登录 - {{ site_info.site_name }}{% endblock %}

{% block content %}
<div class="row justify-content-center">
    <div class="col-md-6">
        <div class="card">
            <div class="card-header bg-primary text-white">
                <h2 class="mb-0">登录</h2>
            </div>
            <div class="card-body">
                {% if form.errors %}
                    <div class="alert alert-danger">
                        <p>用户名或密码不正确。请重试。</p>
                    </div>
                {% endif %}
                
                <form method="post">
                    {% csrf_token %}
                    <input type="hidden" name="next" value="{{ next }}">
                    
                    <div class="mb-3">
                        <label for="id_username" class="form-label">用户名</label>
                        {{ form.username }}
                        {% if form.username.errors %}
                            <div class="invalid-feedback d-block">{{ form.username.errors }}</div>
                        {% endif %}
                    </div>
                    
                    <div class="mb-3">
                        <label for="id_password" class="form-label">密码</label>
                        {{ form.password }}
                        {% if form.password.errors %}
                            <div class="invalid-feedback d-block">{{ form.password.errors }}</div>
                        {% endif %}
                    </div>
                    
                    <div class="mb-3">
                        <label for="id_captcha" class="form-label">验证码</label>
                        {{ form.captcha }}
                        {% if form.captcha.errors %}
                            <div class="invalid-feedback d-block">{{ form.captcha.errors }}</div>
                        {% endif %}
                    </div>
                    
                    <div class="d-grid gap-2 mt-4">
                        <button type="submit" class="btn btn-primary">登录</button>
                    </div>
                </form>
                
                <div class="text-center mt-3">
                    <p>没有账户？<a href="{% url 'accounts:signup' %}">注册</a></p>
                </div>
            </div>
        </div>
    </div>
</div>
{% endblock %} 